package com.wxq.workpad.network.interceptor;

import android.os.Handler;
import android.os.Looper;

public class HandlerUtils {
    private Handler handler = null;

    private HandlerUtils() {
        handler = new Handler(Looper.getMainLooper());
    }

    private static class SingletonHolder {
        private static HandlerUtils instance = new HandlerUtils();
    }

    public static HandlerUtils getInstance() {
        return SingletonHolder.instance;
    }

    public void post(Runnable runnable) {
        if (handler != null) {
            handler.post(runnable);
        }
    }

    public void postDelayed(Runnable runnable, long delay) {
        if (handler != null) {
            handler.postDelayed(runnable, delay);
        }
    }

    public void removeCallbacks(Runnable runnable) {
        if (handler != null) {
            handler.removeCallbacks(runnable);
        }
    }
}
